<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2020/6/23
 * Time: 15:52
 */

namespace app\adminapiv3\controller;


class IpsOriginalRule extends Base
{
    /**
     * @name 列表
     * @author wx
     * @date 2019/11/20 16:38
     */
    public function list($host_id)
    {

        $params['rule'] = $this->filterInput('rule','get');

        $server = new \app\adminapiv3\service\IpsOriginalRule();
        $list = $server->toDo('list',[$host_id, $params, $this->getLimit()]);

        $this->jsonOutPut($list);
    }

    /**
     * @name 打开监控
     * @author wx
     * @date 2019/11/20 16:38
     */
    public function openMonitor($host_id)
    {
        $server = new \app\adminapiv3\service\IpsOriginalRule();
        $id = $this->filterInput('id*');


        $params['status'] = 1;
        $params['host_id'] = $host_id;
        $server->modify($id, $params);

        $this->jsonOutPut([],true);
        $this->Async('Wipf', 'Iptables');
    }

    /**
     * @name 关闭监控
     * @author wx
     * @date 2019/11/20 16:38
     */
    public function closeMonitor($host_id)
    {
        $server = new \app\adminapiv3\service\IpsOriginalRule();
        $id = $this->filterInput('id*');


        $params['status'] = 0;
        $params['host_id'] = $host_id;
        $server->toDo('modify',[$id, $params]);

        $this->jsonOutPut([],true);
        $this->Async('Wipf', 'Iptables');
    }

    /**
     * @name 删除
     * @author wx
     * @date 2019/11/20 16:38
     */
    public function del($host_id)
    {
        $server = new \app\adminapiv3\service\IpsOriginalRule();
        $id = $this->filterInput('id*');

        $server->toDo('del', [$id, $host_id]);

        $this->jsonOutPut([],true);

        $this->Async('Wipf', 'Iptables');
    }

    /**
     * @name: 转换规则并上传
     * @Param:
     * @Description:
     * @Author: wx
     * @Date: 2019-11-29 14:27:03
     */
    public function importRule($host_id)
    {
        $server = new \app\adminapiv3\service\IpsOriginalRule();

        $list = $server->toDo('importRule', [$host_id]);

        $this->jsonOutPut($list, true);

        $this->Async('Wipf', 'Webcmd', ['action' => 'ConvertRule']);
    }
}